#ifndef _BINARYTREE_H_
#define _BINARYTREE_H_

#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <stdexcept>

using namespace std;

namespace BinaryTreeSp {

typedef struct TreeNode_ {
    void * data;
    struct TreeNode_ *left, *right;
} TreeNode;

class BinaryTree {
    public:
    BinaryTree(int (*cmp)(void *data1, void *data2));
    ~BinaryTree();

    TreeNode *getRoot(void);
    int addData(void *data);
    int deleteData(void *data);
    
    void insertNode(TreeNode *root, TreeNode *node);
    int preOrderTraverse(TreeNode *node);
    int inOrderTraverse(TreeNode *node);
    int postOrderTraverse(TreeNode *node);

    private:
    void *getData(TreeNode *root);
    TreeNode *getLeftNode(TreeNode *root);
    TreeNode *getRightNode(TreeNode *root);
    int (*compare)(void *data1, void *data2);
    
    int num;
    TreeNode *root;
};

}

#endif
